package thread;

public class ThreadDemo35 {
    private static int sum = 0;
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                int rs = 0;
                for (int i = 1; i < 1000; i++) {
                    rs += i;
                }
                sum = rs;
            }
        });
        t.start();
        t.join();
        //主线程获取计算结果
        //此处想要获取结果,就需要撞门搞一个成员变量来保存上诉的值
        System.out.println("sum = " + sum);
    }
}
